package com.huaxiafinance.management.service.impl;

import com.huaxiafinance.management.dto.request.trialDto;
import com.huaxiafinance.management.mapper.YfqUserMapper;
import com.huaxiafinance.management.model.YfqUser;
import com.huaxiafinance.management.service.TrialService;
import com.huaxiafinance.management.util.MessageResult;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by huangwencheng on 2017/12/14.
 */
@Service("TrialService")
@SuppressWarnings("SpringJavaAutowiringInspection")
@Transactional
public class TrialServiceImpl implements TrialService {

    private static final Logger log = Logger.getLogger(TrialServiceImpl.class);

    @Autowired
    private YfqUserMapper yfquserMapper;


    /**
     * 查看所有的用户
     *
     * @return
     */
    @Override
    public MessageResult queryAllCustomers(trialDto dto) throws Exception {
        MessageResult messageResult = new MessageResult();
        dto.setPage(dto.getPage() * dto.getRows());
        List<YfqUser> frontUserList = yfquserMapper.queryAllCustomers(dto);
        messageResult.setData(frontUserList);
        //统计数量
        int countResult = yfquserMapper.countAllCustomers(dto);
        messageResult.setRows(countResult);
        messageResult.setSuccessResult();
        return messageResult;
    }

    @Override
    public MessageResult updateUser(String userUuid,Integer type)  throws Exception {
        MessageResult messageResult = new MessageResult();
        yfquserMapper.updateByUserUuid(userUuid,type);
        messageResult.setSuccessResult();
        return messageResult;
    }

}
